<template>
  <div class="app-container">
    <div class="filter-container" >
      <!--<div style="height: 30px;">
        <span>营业汇总表</span>
      </div>-->
      <searchBar @searchEvent= "handleFilter"/>
    </div>

    <div style="height: 50px;margin-top: 20px;padding: 0 12px; background:#eee; line-height: 50px;">
      <span>店铺营运分析报表</span>
    </div>
    <el-table
      v-loading="listLoading"
      :key="tableKey"
      :data="list"
      height="500"
      border
      fit
      highlight-current-row
      style="width: 100%;"
    >
      <el-table-column label="店铺名称" fixed min-width="150" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="用户消费比率" width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.userConsumeRate && scope.row.userConsumeRate || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="回头消费比率" width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.backConsumeRate && scope.row.backConsumeRate || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="新增用户比率" width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.userAddRate && scope.row.userAddRate || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="新增用户渠道" min-width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.userAddWay && scope.row.userAddWay || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="新用户消费" width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.newUserCount && scope.row.newUserCount || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="自然用户" width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.naturalUser && scope.row.naturalUser || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="分享用户" width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.shareUserRate && scope.row.shareUserRate || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="回头用户消费" width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.backUserConsume && scope.row.backUserConsume || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="二次回头" width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.userTwiceBack && scope.row.userTwiceBack || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="多次回头" width="120" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.userMoreBack && scope.row.userMoreBack || 0 }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" />

  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import waves from '@/directive/waves' // Waves directive
import { parseTime } from '@/utils'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination

import searchBar from '@/pages/common/searchBar'
import ReportSearchMixin from '@/pages/common/mixin/ReportSearch.js'

export default {
  name: 'Yingyunfenxi',
  components: { searchBar, Pagination },
  directives: { waves },
  filters: {

  },
  mixins: [ReportSearchMixin],
  data() {
    return {

      tableKey: 0,
      overAll: [], // 品牌的总览数据
      list: [], // 下边的列表数据
      total: 0,
      listLoading: true,
      listQuery: {
        pageNum: 1,
        pageSize: 10,
        beginDate: parseTime(new Date().getTime(), '{y}-{m}-{d} 00:00:00'),
        endDate: parseTime(new Date().getTime(), '{y}-{m}-{d} {h}:{i}:{s}')
      },
      // overAllUrl: '/service-report/businessReport/listTakeOutReport' // 概览接口地址
      listUrl: '/service-report/businessReport/listAnalyzeReport' // 列表接口地址

    }
  },
  created() {
    // this.getList()
    this.fetchData()
  },
  methods: {

    download() {

    },
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total

        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    }
    /* handleFilter(date) {
      this.beginDate = date.beginDate
      this.endDate = date.endDate
      console.log('date', date)
      this.listQuery.page = 1
      this.getList()
    },
    sortChange(data) {
      const { prop, order } = data
      if (prop === 'id') {
        this.sortByID(order)
      }
    }*/

  }
}
</script>
